/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fgv.tcc.fgv.imovel.controlle;

import br.com.fgv.tcc.fgv.imovel.model.TipoUsuario;
import br.com.fgv.tcc.fgv.imovel.model.Usuario;
import br.com.fgv.tcc.fgv.imovel.service.Service;
import br.com.fgv.tcc.fgv.imovel.service.UsuarioService;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import org.apache.log4j.LogManager;

/**
 *
 * @author diego
 */
@Named(value = "clienteM")
@SessionScoped
public class ClienteMBean extends AbstractCrudBean<Usuario> implements Serializable {

    @EJB
    private UsuarioService ejbFacade;

    public ClienteMBean() {
        logger = LogManager.getLogger(Usuario.class.getName());
        selected = new Usuario();
    }

    @Override
    protected Service getServiceManager() {
        return ejbFacade;

    }

    public Usuario getSelected() {
        return selected;
    }

    public void setSelected(Usuario selected) {
        this.selected = selected;
    }

    @Override
    public void novaInstancia() {
        selected = new Usuario();
        selected.setAtivo(true);
        selected.setTipoUsuario(TipoUsuario.CLIENTE);
    }

    public TipoUsuario[] getTipoUsuarios() {
        return TipoUsuario.values();
    }

    @Override
    public List getItems() {
        if (items == null) {
            items = ejbFacade.recuperaClientes();
        }
        System.out.print(items);
        return items;

    }

}
